<style scoped>
  .income{
    /*height:100%;*/
    background: #edf1f5;
  }
  .main{
    /*padding-bottom: 70px;*/
  }
  .nav ul{
    display: flex;
    flex-direction: row;
    padding:8px 0;
    background: #ffffff;
    border-bottom: 1px solid #e9e9e9;
  }
  .nav ul li{
    flex: 1;
  }
  .nav ul li a{
    display: flex;
    flex-direction: row;
    flex: 1;
    justify-content: center;
    align-items: center;
  }
  .nav ul li p{
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
  }
  .nav ul li:first-child p{
    color: #4D63EB;
  }
  .nav ul li:first-child p b{
    width:50%;
    height:3px;
    background: -webkit-linear-gradient(right, #91A5F8, #6379F8);
    position: absolute;
    left:25%;
    bottom:-8px;
  }
  .nav ul li h4{
    color: #e9e9e9;
  }
  .weight-top{
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    border-bottom: 1px solid #e9e9e9;
  }
  .weight-top div{
    display: flex;
    flex-direction: row;
    align-items:center;
    justify-content: center;
  }
  .weight-top div h4{
    opacity: 0.5;
  }
  .weight-top div h3{
    opacity: 0.5;
    margin-left: 4px;
  }
  .profit{
  }
  .line1{
    height:200px;
    /*border-bottom: 6px solid #eeedf4;*/
    overflow: hidden;
    background: #ffffff;
  }
  .echarts {
    height: 200px;
    width:100%;
  }
  /*.echarts>div:first-child{*/
  /*width:100%;*/
  /*}*/
  .ryn{
    display: flex;
    flex-direction: row-reverse;
    padding: 10px 0;
    background: #ffffff;
  }
  .ryn ul{
    display: flex;
    margin-right: 20px;
  }
  .ryn ul li{
    width:26px;
    height: 26px;
    border: 1px solid #82A8FF;
    border-radius: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-left: 10px;
  }
  .ryn ul li.active{
    background: #6683ff;

  }
  .ryn ul li p{
    color: #6683ff;
  }
  .ryn ul li.active p{
    color: #ffffff;
  }
  .weight-top{
    background: #ffffff;
  }
  .fenxi{
    background: #ffffff;
    /*border-bottom: 1px solid #e9e9e9;*/
  }
  .fenxi>div{
    display: flex;
    flex-direction: row;
    border-bottom: 1px solid #e9e9e9;
  }
  .fenxi>div>h3{
    flex: 3;
    display: flex;
    justify-content: center;
    padding-top: 10px;
  }
  .fenxi ul{
    display: flex;
    flex: 7;
    flex-direction: column;
  }
  .fenxi ul li{
    display: flex;
    justify-content: space-between;
    padding:10px 10px;
    align-items: center;
    border-bottom: 1px solid #e9e9e9;
  }
  .fenxi ul li:last-child{
    border-bottom: none;
  }
  .fenxi ul li>div{
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }
  .fenxi ul li>div>h2{
    color: #F84949;
    display: flex;
    flex-direction: row;
  }
  .fenxi ul li>div p{
    color: #F84949;
  }
  .green{
    color: #7ed321;
  }
  .fenxi ul li>div>h2>h3{
    color: #F84949;
    margin-top: 2px;
  }
  .fenxi ul li>div>h4{
    opacity: 0.5;
  }

  .unChoose{
    border-color: #e9e9e9!important;
    background: #FFFFFF!important;
  }
  .unChoose p{
    /*background: #e9e9e9;*/
    color: #e9e9e9!important;
  }

  .profit2{
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
  }
  .profit2 p{
    margin-top: 10px;
  }
  .profit2 h3{
    text-align: center;
    color: #6379F8;
  }

</style>
<template>
  <div class="income">
    <div class="main">
    <v-scroller
    style="margin-top: 97px"
    height="-146px"
    v-on:reload="findData"
    v-if="isIncomeAccount"
    ref="scrollBar">
      <div class="profit">
        <div class="ryn">
          <ul>
            <li @click="week" v-bind:class="{active:weekActive}"><p>周</p></li>
            <li @click="month" v-bind:class="{active:monthActive,unChoose: hasMonth}"><p>月</p></li>
            <li @click="year" v-bind:class="{active:yearActive,unChoose: hasYear}"><p>年</p></li>
          </ul>
        </div>
        <div class="line1">
          <chart :options="line"></chart>
        </div>
        <div class="weight-top">
          <p>收益率分析</p>
        </div>
        <div class="fenxi">
          <div class="my-income">
            <h3>盈透证券</h3>
            <ul>
              <li>
                <div>
                  <h2 v-if="allData.portfolioStat.dr>0.0001" style="color: #F84949;">{{allData.portfolioStat.dr | percent}}<h3 style="color: #F84949;">%</h3></h2>
                  <h2 v-else-if="allData.portfolioStat.dr<0.0001" style="color: #093;">{{allData.portfolioStat.dr | percent}}<h3 style="color: #093;">%</h3></h2>
                  <h2 v-else="allData.portfolioStat.dr<=0.0001 && all.dr>=-0.0001" style="color: #666;">{{allData.portfolioStat.dr | percent}}<h3>%</h3></h2>
                  <!--<h2>{{allData.portfolioStat.dr | percent}}<h3>%</h3></h2>-->
                  <h4>当日收益率</h4>
                </div>
                <div>
                  <h2 v-if="allData.portfolioStat.mr>0.0001" style="color: #F84949;">{{allData.portfolioStat.mr | percent}}<h3 style="color: #F84949;">%</h3></h2>
                  <h2 v-else-if="allData.portfolioStat.mr<0.0001" style="color: #093;">{{allData.portfolioStat.mr | percent}}<h3 style="color: #093;">%</h3></h2>
                  <h2 v-else="allData.portfolioStat.mr<=0.0001 && all.mr>=-0.0001" style="color: #666;">{{allData.portfolioStat.mr | percent}}<h3>%</h3></h2>
                  <!--<h2>{{allData.portfolioStat.mr | percent}}<h3>%</h3></h2>-->
                  <h4>本月收益率</h4>
                </div>
                <div>
                  <h2 v-if="allData.portfolioStat.yr>0.0001" style="color: #F84949;">{{allData.portfolioStat.yr | percent}}<h3 style="color: #F84949;">%</h3></h2>
                  <h2 v-else-if="allData.portfolioStat.yr<0.0001" style="color: #093;">{{allData.portfolioStat.yr | percent}}<h3 style="color: #093;">%</h3></h2>
                  <h2 v-else="allData.portfolioStat.yr<=0.0001 && all.yr>=-0.0001" style="color: #666;">{{allData.portfolioStat.yr | percent}}<h3>%</h3></h2>
                  <!--<h2>{{allData.portfolioStat.yr | percent}}<h3>%</h3></h2>-->
                  <h4>本年收益率</h4>
                </div>
              </li>
              <li>
                <div>
                  <h2 v-if="allData.portfolioStat.dprofit>0.0001" style="color: #F84949;">{{allData.portfolioStat.dprofit | toFiexed0}}</h2>
                  <h2 v-if="allData.portfolioStat.dprofit<-0.0001" style="color: #093;">{{allData.portfolioStat.dprofit | toFiexed0}}</h2>
                  <h2 v-if="allData.portfolioStat.dprofit>=-0.0001 && allData.portfolioStat.dprofit<=0.0001" style="color: #093;">{{allData.portfolioStat.dprofit | toFiexed0}}</h2>
                  <!--<p>{{allData.portfolioStat.dprofit | toFixed}}</p>-->
                  <h4>当日收益</h4>
                </div>
                <div>
                  <h2 v-if="allData.portfolioStat.mprofit>0.0001" style="color: #F84949;">{{allData.portfolioStat.mprofit | toFiexed0}}</h2>
                  <h2 v-if="allData.portfolioStat.mprofit<-0.0001" style="color: #093;">{{allData.portfolioStat.mprofit | toFiexed0}}</h2>
                  <h2 v-if="allData.portfolioStat.mprofit>=-0.0001 && allData.portfolioStat.mprofit<=0.0001" style="color: #666;">{{allData.portfolioStat.mprofit | toFiexed0}}</h2>
                  <!--<p>{{allData.portfolioStat.mprofit | toFixed}}</p>-->
                  <h4>本月收益</h4>
                </div>
                <div>
                  <h2 v-if="allData.portfolioStat.yprofit>0.0001" style="color: #F84949;">{{allData.portfolioStat.yprofit | toFiexed0}}</h2>
                  <h2 v-if="allData.portfolioStat.yprofit<-0.0001" style="color: #093;">{{allData.portfolioStat.yprofit | toFiexed0}}</h2>
                  <h2 v-if="allData.portfolioStat.yprofit>=-0.0001 && allData.portfolioStat.yprofit<=0.0001" style="color: #666;">{{allData.portfolioStat.yprofit | toFiexed0}}</h2>
                  <!--<p>{{allData.portfolioStat.yprofit | toFixed}}</p>-->
                  <h4>本年收益</h4>
                </div>
              </li>
            </ul>
          </div>
          <div class="base-income">
            <h3>基准组合</h3>
            <ul>
              <li>
                <div>
                  <h2 v-if="allData.portfolioStat.dr>0.0001" style="color: #F84949;">{{allData.benchmarkStat.dr | percent}}<h3 style="color: #F84949;">%</h3></h2>
                  <h2 v-else-if="allData.portfolioStat.dr<0.0001" style="color: #093;">{{allData.benchmarkStat.dr | percent}}<h3 style="color: #093;">%</h3></h2>
                  <h2 v-else="allData.portfolioStat.dr<=0.0001 && all.dr>=-0.0001" style="color: #666;">{{allData.benchmarkStat.dr | percent}}<h3>%</h3></h2>
                  <!--<h2>{{allData.portfolioStat.dr | percent}}<h3>%</h3></h2>-->
                  <h4>当日收益率</h4>
                </div>
                <div>
                  <h2 v-if="allData.portfolioStat.mr>0.0001" style="color: #F84949;">{{allData.benchmarkStat.mr | percent}}<h3 style="color: #F84949;">%</h3></h2>
                  <h2 v-else-if="allData.portfolioStat.mr<0.0001" style="color: #093;">{{allData.benchmarkStat.mr | percent}}<h3 style="color: #093;">%</h3></h2>
                  <h2 v-else="allData.portfolioStat.mr<=0.0001 && all.mr>=-0.0001" style="color: #666;">{{allData.benchmarkStat.mr | percent}}<h3>%</h3></h2>
                  <!--<h2>{{allData.portfolioStat.mr | percent}}<h3>%</h3></h2>-->
                  <h4>本月收益率</h4>
                </div>
                <div>
                  <h2 v-if="allData.portfolioStat.yr>0.0001" style="color: #F84949;">{{allData.benchmarkStat.yr | percent}}<h3 style="color: #F84949;">%</h3></h2>
                  <h2 v-else-if="allData.portfolioStat.yr<0.0001" style="color: #093;">{{allData.benchmarkStat.yr | percent}}<h3 style="color: #093;">%</h3></h2>
                  <h2 v-else="allData.portfolioStat.yr<=0.0001 && all.yr>=-0.0001" style="color: #666;">{{allData.benchmarkStat.yr | percent}}<h3>%</h3></h2>
                  <!--<h2>{{allData.portfolioStat.yr | percent}}<h3>%</h3></h2>-->
                  <h4>本年收益率</h4>
                </div>
              </li>
            </ul>
          </div>
        </div>
      </div>
      </v-scroller>
      <div class="profit2" style="padding-top: 180px" v-else-if="isAccount">
          <img src="../../assets/img/sad.png" alt="" width="83" height="95">
          <div>
            <p>没开户就没有收益哦~</p>
            <h3 @click="toOpen">马上去开户</h3>
          </div>
      </div>
      <div class="profit2" style="padding-top: 180px" v-else-if="isIncome">
        <img src="../../assets/img/sad.png" alt="" width="83" height="95">
        <div>
          <p>没交易就没有收益哦~</p>
          <h3 @click="toTrade">马上去交易</h3>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  import host from '../../config.js'
  import axios from 'axios'
  import ECharts from 'vue-echarts/components/ECharts.vue'
  import echart from 'echarts'
  import 'echarts/lib/chart/line'



  export default {
    components: {
      chart: ECharts
    },
    data () {
      return {
        isIncomeAccount: null,
//        是否开户
        isAccount: null,
//        是否交易
        isIncome: null,
        token: null,
        line: null,
        allData: {
          portfolioN: null,
          benchmarkN: null,
          portfolioStat: {
            "dr": null,
            "mr": null,
            "yr": null,
            "dprofit": null,
            "mprofit": null,
            "yprofit": null
          },
          "benchmarkStat": {
            "dr": null,
            "mr": null,
            "yr": null
          },
          date: null
        },
        //      月周年
        weekActive: false,
        monthActive:false,
        yearActive: true,

        hasMonth: true,
        hasYear: true
      }
    },
    activated () {
      this.findData()
    },
    beforeRouteEnter (to, from, next) {
      next((vm) => {
        vm.$refs.scrollBar.$refs.scrollBar.donePulldown()
      })
    },
    methods: {
      findData () {
      var localStorage = window.localStorage
      let that = this
      axios({
        method: 'get',
        headers: {'Authorization': window.localStorage.getItem('token')},
        url: host.host + "/api/trade/capital"
      }).then(function (data) {
        if(data.data.code === 6006) {
          that.$router.push('../login')
        }
        if(data.data.code === 6007) {
          that.$refreshToken()
        }
        if(data.data.code === 200) {
          let getData = data.data.data
          if(getData.total_position){
            that.isIncomeAccount = true
          }
        }else{
          that.hasAccount()
        }
      })



      //    页面总数据
      axios({
        method: 'GET',
        headers: {'Authorization': window.localStorage.getItem('token')},
        url: host.host + "/api/trade/profitAnalysis"
      }).then(function (data) {
        var xdata = []
        that.line = {
          tooltip: {
            show: true,
            trigger: 'axis'
          },
          grid: {
            left: '2%',
            top: '4%',
            right: '3%',
            bottom: '3%'
          },
          xAxis: [
            {
              splitLine: {
                show: false
              },
              boundaryGap: false,
              axisLabel: {
                show: false
              },
              axisTick: false,
              axisLine: {
                lineStyle: {
                  color: '#e9e9e9',
                  opacity: 1
                }
              },
              data: xdata
            }
          ],
          yAxis: [
            {
              type: 'value',
              splitNumber: 3,
              splitLine: {
                show: true,
                lineStyle:{
                  color: '#e9e9e9',
                  opacity: 0.5
                }
              },
              boundaryGap: false,
              axisLabel: {
                show: true
              },
              axisLine: {
                show: false,
                lineStyle: {
                  color: '#e9e9e9',
                  opacity: 0.8
                }
              },
              axisTick: false
            }
          ],
          series: [
            {
              name: data.data.data.benchmark.name,
              type: 'line',
              areaStyle: {
                normal: {
                  color: new echart.graphic.LinearGradient(
                    0, 0, 0, 1,
                    [
                      {offset: 0, color: '#EEF1FF'},
                      {offset: 1, color: '#7792FF'}
                    ]
                  )
                }
              },
              itemStyle: {
                normal: {
                  color: '#7792FF'
                }
              },
              data: []
            },
            {
              name: '本组合收益(%)',
              type: 'line',
              stack: '总量',
              areaStyle: {
                normal: {
                  color: new echart.graphic.LinearGradient(
                    0, 0, 0, 1,
                    [
                      {offset: 0, color: '#EEF1FF'},
                      {offset: 1, color: '#F35555'}
                    ]
                  )
                }
              },
              itemStyle: {
                normal: {
                  color: '#F84949'
                }
              },
              data: []
            }
          ]
        }
        if(data.data.code === 6006) {
          that.$router.push('../login')
        }
        if(data.data.code === 6007){
          that.$refreshToken()
        }
        if(data.data.code === 200) {
          that.allData = data.data.data
          that.weekActive = true
          if (that.allData.benchmarkN.length > 5) {
            that.hasMonth = false
          }
          if (that.allData.benchmarkN.length > 22) {
            that.hasYear = false
          }
          var dataLength = that.allData.benchmarkN.length
          var dataLength5
          if(dataLength > 5) {
            dataLength5 = dataLength - 5
          }else{
            dataLength5 = 0
          }
          for(var i = dataLength5; i < dataLength; i++){
            that.line.series[0].data.push((that.allData.benchmarkN[i]*100).toFixed(2))
          }
          for(var j = dataLength5; j < dataLength; j++){
            that.line.series[1].data.push((that.allData.portfolioN[j]*100).toFixed(2))
          }
          for(var k = dataLength5; k < dataLength; k++){
            xdata.push((that.allData.date[k]))
          }
        }
        that.$nextTick(() => {
          that.$refs.scrollBar.$refs.scrollBar.reset()
        })
      })
      },
      year () {
        if(this.hasYear) return
        this.weekActive = false
        this.monthActive = false
        this.yearActive = true
        var xdata = []
        this.line = {
          tooltip: {
            show: true,
            trigger: 'axis'
          },
          grid: {
            left: '2%',
            top: '4%',
            right: '3%',
            bottom: '3%'
          },
          xAxis: [
            {
              splitLine: {
                show: false
              },
              boundaryGap: false,
              axisLabel: {
                show: false
              },
              axisTick: false,
              axisLine: {
                lineStyle: {
                  color: '#e9e9e9',
                  opacity: 1
                }
              },
              data: xdata
            }
          ],
          yAxis: [
            {
              type: 'value',
              splitNumber: 3,
              splitLine: {
                show: true,
                lineStyle:{
                  color: '#e9e9e9',
                  opacity: 0.5
                }
              },
              boundaryGap: false,
              axisLabel: {
                show: true
              },
              axisLine: {
                show: false,
                lineStyle: {
                  color: '#e9e9e9',
                  opacity: 0.8
                }
              },
              axisTick: false
            }
          ],
          series: [
            {
              name: this.allData.benchmark.name,
              type: 'line',
              areaStyle: {
                normal: {
                  color: new echart.graphic.LinearGradient(
                    0, 0, 0, 1,
                    [
                      {offset: 0, color: '#EEF1FF'},
                      {offset: 1, color: '#7792FF'}
                    ]
                  )
                }
              },
              itemStyle: {
                normal: {
                  color: '#7792FF'
                }
              },
              data: []
            },
            {
              name: '本组合收益(%)',
              type: 'line',
              stack: '总量',
              areaStyle: {
                normal: {
                  color: new echart.graphic.LinearGradient(
                    0, 0, 0, 1,
                    [
                      {offset: 0, color: '#EEF1FF'},
                      {offset: 1, color: '#F35555'}
                    ]
                  )
                }
              },
              itemStyle: {
                normal: {
                  color: '#F84949'
                }
              },
              data: []
            }
          ]
        }
        var dataLength = this.allData.benchmarkN.length
        for(var i = 0; i < dataLength; i++){
          this.line.series[0].data.push((this.allData.benchmarkN[i]*100).toFixed(2))
        }
        for(var j = 0; j < dataLength; j++){
          this.line.series[1].data.push((this.allData.portfolioN[j]*100).toFixed(2))
        }
        for(var k = 0; k < dataLength; k++){
          xdata.push((this.allData.date[k]))
        }
      },
      month () {
        if(this.hasMonth) return
        this.weekActive = false
        this.monthActive = true
        this.yearActive = false
        var xdata = []
        this.line = {
          tooltip: {
            show: true,
            trigger: 'axis'
          },
          grid: {
            left: '2%',
            top: '4%',
            right: '3%',
            bottom: '3%'
          },
          xAxis: [
            {
              splitLine: {
                show: false
              },
              boundaryGap: false,
              axisLabel: {
                show: false
              },
              axisTick: false,
              axisLine: {
                lineStyle: {
                  color: '#e9e9e9',
                  opacity: 1
                }
              },
              data: xdata
            }
          ],
          yAxis: [
            {
              type: 'value',
              splitNumber: 3,
              splitLine: {
                show: true,
                lineStyle:{
                  color: '#e9e9e9',
                  opacity: 0.5
                }
              },
              boundaryGap: false,
              axisLabel: {
                show: true
              },
              axisLine: {
                show: false,
                lineStyle: {
                  color: '#e9e9e9',
                  opacity: 0.8
                }
              },
              axisTick: false
            }
          ],
          series: [
            {
              name: this.allData.benchmark.name,
              type: 'line',
              areaStyle: {
                normal: {
                  color: new echart.graphic.LinearGradient(
                    0, 0, 0, 1,
                    [
                      {offset: 0, color: '#EEF1FF'},
                      {offset: 1, color: '#7792FF'}
                    ]
                  )
                }
              },
              itemStyle: {
                normal: {
                  color: '#7792FF'
                }
              },
              data: []
            },
            {
              name: '本组合收益(%)',
              type: 'line',
              stack: '总量',
              areaStyle: {
                normal: {
                  color: new echart.graphic.LinearGradient(
                    0, 0, 0, 1,
                    [
                      {offset: 0, color: '#EEF1FF'},
                      {offset: 1, color: '#F35555'}
                    ]
                  )
                }
              },
              itemStyle: {
                normal: {
                  color: '#F84949'
                }
              },
              data: []
            }
          ]
        }
        var dataLength = this.allData.benchmarkN.length
        var dataLength22
        if(dataLength > 22) {
          dataLength22 = dataLength - 22
        }else{
          dataLength22 = 0
        }
        for(var i = dataLength22; i < dataLength; i++){
          this.line.series[0].data.push((this.allData.benchmarkN[i]*100).toFixed(2))
        }
        for(var j = dataLength22; j < dataLength; j++){
          this.line.series[1].data.push((this.allData.portfolioN[j]*100).toFixed(2))
        }
        for(var k = dataLength22; k < dataLength; k++){
          xdata.push((this.allData.date[k]))
        }
      },
      week () {
        this.weekActive = true
        this.monthActive = false
        this.yearActive = false
        var xdata = []
        this.line = {
          tooltip: {
            show: true,
            trigger: 'axis'
          },
          grid: {
            left: '2%',
            top: '4%',
            right: '3%',
            bottom: '3%'
          },
          xAxis: [
            {
              splitLine: {
                show: false
              },
              boundaryGap: false,
              axisLabel: {
                show: false
              },
              axisTick: false,
              axisLine: {
                lineStyle: {
                  color: '#e9e9e9',
                  opacity: 1
                }
              },
              data: xdata
            }
          ],
          yAxis: [
            {
              type: 'value',
              splitNumber: 3,
              splitLine: {
                show: true,
                lineStyle:{
                  color: '#e9e9e9',
                  opacity: 0.5
                }
              },
              boundaryGap: false,
              axisLabel: {
                show: true
              },
              axisLine: {
                show: false,
                lineStyle: {
                  color: '#e9e9e9',
                  opacity: 0.8
                }
              },
              axisTick: false
            }
          ],
          series: [
            {
              name: this.allData.benchmark.name,
              type: 'line',
              areaStyle: {
                normal: {
                  color: new echart.graphic.LinearGradient(
                    0, 0, 0, 1,
                    [
                      {offset: 0, color: '#EEF1FF'},
                      {offset: 1, color: '#7792FF'}
                    ]
                  )
                }
              },
              itemStyle: {
                normal: {
                  color: '#7792FF'
                }
              },
              data: []
            },
            {
              name: '本组合收益(%)',
              type: 'line',
              stack: '总量',
              areaStyle: {
                normal: {
                  color: new echart.graphic.LinearGradient(
                    0, 0, 0, 1,
                    [
                      {offset: 0, color: '#EEF1FF'},
                      {offset: 1, color: '#F35555'}
                    ]
                  )
                }
              },
              itemStyle: {
                normal: {
                  color: '#F84949'
                }
              },
              data: []
            }
          ]
        }
        var dataLength = this.allData.benchmarkN.length
        for(var i = (dataLength - 5); i < dataLength; i++){
          this.line.series[0].data.push((this.allData.benchmarkN[i]*100).toFixed(2))
        }
        for(var j = (dataLength - 5); j < dataLength; j++){
          this.line.series[1].data.push((this.allData.portfolioN[j]*100).toFixed(2))
        }
        for(var k = (dataLength - 5); k < dataLength; k++){
          xdata.push((this.allData.date[k]))
        }

      },
      toOpen () {
        this.$router.push('../open2')
      },
      toTrade () {
        this.$router.push('../all')
      },
      hasAccount() {
        var localStorage = window.localStorage
        let that = this
        axios({
          method: 'GET',
          headers: {'Authorization': window.localStorage.getItem('token')},
          url: host.host + "/api/trade/iBind"
        }).then(function (data) {
          if(data.data.code === 6006) {
            that.$router.push('../login')
          }
          if(data.data.code === 6007){
            that.$refreshToken()
          }
          if(data.data.code === 6008) {
            that.isAccount = true
          } else if (data.data.code === 200) {
            if(data.data.data.account){
              that.isIncome = true
            }
          }
        })
      }
    },
    filters: {
      percent (data) {
        if(data) {
          return (parseFloat(data) * 100).toFixed(2)
        } else {
          return 0
        }
      },
      toFixed (data) {
        if (data) {
          return (parseFloat(data)).toFixed(2)
        } else {
          return 0
        }
      },
      toFiexed0 (data) {
        if (data) {
          return (parseFloat(data)).toFixed(0)
        } else {
          return 0
        }
      }
    }
  }
</script>
